package hij;
public class arrayqueue implements queue{
        private int front;
	private int rear;
	private Object a[];
        
        public arrayqueue(){
            this.front=0;
            this.rear=0;
            this.a=new Object[100];
        }
        
        public boolean isEmpty(){
            return this.front==this.rear;
        }
        
        public Object getFront(){
            if(this.isEmpty()==true)
                throw new IllegalArgumentException("队已经为空");
            return this.a[this.front];
        }
        
        public void clear(){
            this.front=0;
            this.rear=0;
        }
        
        public void enQueue(Object o){
            if((this.rear+1)%100==this.front)
                throw new IllegalArgumentException("队已经为满");
            this.a[this.rear]=o;
            this.rear=(this.rear+1)%100;
        }
        
        public Object deQueue(){
            if(this.isEmpty()==true)
                throw new IllegalArgumentException("队已经为空");
            Object c=this.a[this.front];
            this.front=(this.front+1)%100;
            return c;
        }
}
